home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / t_os / fs201q0 / rs232c.s < prev   
Text File  |  1993-07-08  |  2KB  |  114 lines

  1. /*
  2.     functions for GNU assembler
  3.     by EF-3civic
  4. */
  5.     .globl _RS_GETCH
  6.     .globl _RS_PUTCH
  7.     .globl _RS_STAT
  8.     .globl _RS_CMD
  9.     .globl _RS_INIT
  10.  
  11. /******************************************
  12.     RS232C hardware access functions 
  13.  ******************************************/
  14.     .data
  15.     .text
  16. /*
  17.     int RS_GETCH() get byte with wait
  18. */
  19.     .align 4
  20. _RS_GETCH:
  21.     movw $0xa02,%dx
  22. L1: movl $0x5,%ecx
  23. LA:    loop LA
  24.     inb    %dx,%al
  25.     testb $0x2,%al
  26.     jz    L1
  27.     movl $0x5,%ecx
  28. LB:    loop LB
  29.     movw $0xa00,%dx
  30.     inb    %dx,%al
  31.     movzbl %al,%eax
  32.     movl $0x5,%ecx
  33. LC:    loop LC
  34.     ret
  35.  
  36. /*
  37.     void RS_PUTCH(int data) put byte with wait
  38. */
  39.     .align 4
  40. _RS_PUTCH:
  41.     movw $0xa02,%dx
  42. L2: movl $0x5,%ecx
  43. LD:    loop LD
  44.     inb    %dx,%al
  45.     testb $0x1,%al
  46.     jz    L2
  47.     movl $0x5,%ecx
  48. LE:    loop LE
  49.     movw $0xa00,%dx
  50.     movb 4(%esp),%al
  51.     outb %al,%dx
  52.     movl $0x5,%ecx
  53. LF:    loop LF
  54.     ret
  55.  
  56. /*
  57.     int RS_STAT() read RS status
  58. */
  59.     .align 4
  60. _RS_STAT:
  61.     movw $0xa02,%dx
  62.     inb    %dx,%al
  63.     movzbl %al,%eax
  64.     movl $0x5,%ecx
  65. LG:    loop LG
  66.     ret
  67.  
  68. /*
  69.     void RS_CMD(int data) set RS command
  70. */
  71.     .align 4
  72. _RS_CMD:
  73.     movw $0xa02,%dx
  74.     movb 4(%esp),%al
  75.     outb %al,%dx
  76.     movl $0x5,%ecx
  77. LH:    loop LH
  78.     ret
  79.  
  80. /*
  81.     void RS_INIT() initialize
  82. */
  83.     .align 4
  84. _RS_INIT:
  85.     xorb %al,%al
  86.     movw $0xa08,%dx
  87.     outb %al,%dx
  88.     movl $0x5,%ecx
  89. LI:    loop LI
  90.     movw $0xa02,%dx
  91.     outb %al,%dx
  92.     movl $0x100,%ecx
  93. LJ:    loop LJ
  94.     outb %al,%dx
  95.     movl $0x100,%ecx
  96. LK:    loop LK
  97.     outb %al,%dx
  98.     movl $0x100,%ecx
  99. LL:    loop LL
  100.     movb $0x40,%al
  101.     outb %al,%dx
  102.     movl $0x100,%ecx
  103. LM:    loop LM
  104.     movb $0x4e,%al
  105.     outb %al,%dx
  106.     movl $0x100,%ecx
  107. LN:    loop LN
  108.     movb $0x37,%al
  109.     outb %al,%dx
  110.     movl $0x5,%ecx
  111. LO:    loop LO
  112.     ret
  113.  
  114.